
string file = getenv("TMP1");
string DET = "dcTa";

void a(vector<TH2F *> &v, TObject *h){
  v.push_back((TH2F *)h);
} // end if

void cc(int id, const string &t, const string &p, string &cmd){
  char ii[64]; sprintf(ii, "%d", id); string i = ii;
  cmd = t+"3D.GetHitPosY(\""+p+"\"):"+t+"3D.GetHitPosX(\""+p+"\")>>h"+ii+
    "(500, -100., 100., 500, -100., 100.)";
} // end cc

void p42(){
  TFile *f = new TFile(file.c_str(), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  string c;
  vector<TH2F *> v;

  // --------------------- 11. 2D Pos Plot ----------------------- //
  cc(1,"ta4Tracker", "dcTaU0", c); etf->Draw(c.c_str()); a(v,f->Get("h1"));
  v[0]->GetXaxis()->SetTitle("X -> west(away from CSRe)");
  v[0]->GetYaxis()->SetTitle("Y -> up");
  cc(2,"ta4Tracker", "dcTaU1", c); etf->Draw(c.c_str()); a(v,f->Get("h2"));
  cc(3,"ta4Tracker", "dcTaD0", c); etf->Draw(c.c_str()); a(v,f->Get("h3"));
  cc(4,"ta4Tracker", "dcTaD1", c); etf->Draw(c.c_str()); a(v,f->Get("h4"));


  TCanvas *c1 = new TCanvas("c", "2D Pos Plot", 1680, 1050);
  c1->Divide(2,2);
  for(int i = 0; i < 4; i++){
    c1->cd(i+1); v[i]->Draw("col");
  } // end for
  c1->Print("p42.pdf");
} // end vis
